<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/25
 * Time: 15:20
 */
namespace app\home\model;

use think\Model;
use think\facade\Cookie;
use think\model\concern\SoftDelete;

class Order extends Model
{

    use SoftDelete;
    protected $autoWriteTimestamp = 'datetime';
    protected $pk = 'id';
    protected $deleteTime = 'delete_time';
    protected $table = 'visiting';
    protected $createTime = 'create_time';


    /**
     * 添加编辑参观记录
     * @param $data
     * @return array
     * Date: 2018/10/30 12:31
     * Author: Ning <nono0903@gmail.com>
     */
    public static function addeditVisit($data)
    {
        $msg = info('操作失败!', 0);
        $orderModel = new Order();
        if (isset($data['id'])) {
            $res = $orderModel->allowField(true)->save($data, ['id' => $data['id']]);
        } elseif ($data['act'] == 'add') {

            $res = Order::create($data);
        }

        if ($res) $msg = info('操作成功！', 1, '/myOrder');
        return $msg;
    }

}